package com.woniu108.order.service.impl;


import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu108.order.client.PersonClient;
import com.woniu108.order.mapper.PreInfoMapper;
import com.woniu108.order.model.dto.PreInfoDto;
import com.woniu108.order.model.model.PreInfo;
import com.woniu108.order.model.param.PreInfoQueryToManagerParam;
import com.woniu108.order.service.PreInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 预约服务详情表 服务实现类
 * </p>
 *
 * @author yanxi
 * @since 2024-05-23
 */
@Service
public class PreInfoServiceImpl extends ServiceImpl<PreInfoMapper, PreInfo> implements PreInfoService {
    @Resource
    private PreInfoMapper preInfoMapper;
    @Resource
    private PersonClient personClient;
    @Override
    public List<PreInfoDto> selectPreInfoToManager(PreInfoQueryToManagerParam param) {
        QueryWrapper<PreInfo> queryWrapper = new QueryWrapper<>();
        //根据服务id查询
        if(!param.getServiceId().isEmpty()){
            queryWrapper.like("service_id",param.getServiceId());
        }
        //根据商品id
        if(param.getStoreId()!=null){
            queryWrapper.eq("store_id",param.getStoreId());
        }
        //
        if(!param.getPreMaxTime().isEmpty()||!param.getPreMinTime().isEmpty()) {
            queryWrapper.between("pre_time",param.getPreMinTime().isEmpty()?null: DateUtil.parse(param.getPreMinTime(),"yyyy-MM-dd HH:mm:ss").toString(),param.getPreMaxTime().isEmpty()?null:DateUtil.parse(param.getPreMaxTime(),"yyyy-MM-dd HH:mm:ss").toString());
        }
        return null;
    }
}
